import { BASE_URL, TIME_OUT } from "@/services/config";
import MyRequest from "@/services/request";
import { localCache } from "@/utils/cache";
import { LOGIN_TOKEN } from "@/constants";

export const request = new MyRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestSuccessFn: (config) => {
      console.log("实例请求成功的拦截")
      const token = localCache.getCache(LOGIN_TOKEN);
      if (token && config.headers) {
        config.headers.Authorization = `Bearer ${token}`;
      }
      return config;
    }
  }
});
